--在此宣判
local zaicixuanpan = fk.CreateSkill {
    name = "mcdh_zaicixuanpan",
    tags = {Skill.Compulsory}
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

zaicixuanpan:addEffect(fk.EventPhaseStart,{
    can_trigger=function (self, event, target, player, data)
        return player:hasSkill(zaicixuanpan.name) and target == player and data.phase == Player.Finish
    end,
    on_use=function (self, event, target, player, data)
        local room = player.room
        player:drawCards(1,zaicixuanpan.name)
        lib.askForPublicCard(room,player,player,1,1,zaicixuanpan.name,false,"#zaicixuanpan-public",".",false)
    end
})

zaicixuanpan:addEffect(fk.CardUsing,{
    can_trigger=function (self, event, target, player, data)
        if player:hasSkill(zaicixuanpan.name) and target ~= player and #lib.getPublicCards(player) ~= 0 then
            local use_events = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function (e)
            local use = e.data
            return use.card.type == Card.TypeTrick and use.from == target
        end, Player.HistoryTurn)
        return #use_events == 1 and use_events[1].id == player.room.logic:getCurrentEvent().id
        end
    end,
    on_use=function (self, event, target, player, data)
        local room = player.room
        data:removeAllTargets()
        room:loseHp(player,1,zaicixuanpan.name)
    end
})

Fk:loadTranslationTable {
    ["mcdh_zaicixuanpan"] = "在此宣判",
    [":mcdh_zaicixuanpan"] = "锁定技，结束阶段，你摸并明置一张牌。当其他角色每回合首次使用锦囊牌时，若你有明置牌，你令之无效并失去1点体力。",
    ["#zaicixuanpan-publi"] = "在此宣判: 明置一张牌 ",
}

return zaicixuanpan